﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <div id="js-console"></div>
    <script src="../scripts/js-console.js"></script>\
    <script>

        function Solve(params) {
            var N = parseInt(params[0]);
            var numbers = [];
            for (var i = 1; i < params.length; i++) {
                numbers[i - 1] = parseInt(params[i]);
            }

            var maxSum = Math.pow(Math.max.apply(null,numbers), numbers.length);
            maxSum = (maxSum < 0) ? maxSum = maxSum : maxSum * -1;

            for (var i = 0; i < numbers.length; i++) {
                var currentSum = 0;
                for (var j = i; j < numbers.length; j++) {
                    currentSum += numbers[j];
                    if (currentSum > maxSum) {
                        maxSum = currentSum;
                    }
                }                
            }

            return maxSum;
        }


        jsConsole.writeLine(Solve(["9", "-9", "-8", "-8", "-7", "-6", "-5", "-1", "-7", "-6"]));
    </script>
</body>
</html>
